﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FCA.Dto {
    public class IndexTable {
        /// <summary>
        /// int - int is item - index 
        /// index is the index of the current item in list of concepts 
        /// (list of concetps means all concepts in a lattice)
        /// </summary>
        public Dictionary<int, int> Indexs { get; set; }

        #region Constructors
        public IndexTable() {
            Indexs = new Dictionary<int, int>();
        }       
        #endregion
        public void AddIndex(int i, int conceptID) {
            Indexs[i] = conceptID;
        }

        public void UpdateIndexIfExisted(int i, int conceptID, int oldValue) {
            if (Indexs.ContainsKey(i) && Indexs[i] == oldValue) {
                Indexs[i] = conceptID;
            }
        }


        public bool ContainsKey(int i) {
            return Indexs.ContainsKey(i);
        }

        public int GetFirstNode(int i) {
            if (Indexs.ContainsKey(i)) {
                return Indexs[i];
            } else {
                return -1;
            }
        }
    }
}
